var t = require("../../../@babel/runtime/helpers/typeof"), a = getApp();

Page({
    data: {
        language: "",
        active: 0,
        allData: {},
        member: {},
        rewards: {},
        name: {},
        rewards_type: 1,
        recordsList: [],
        amount_id: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        this.checkrouter(), this.getStatistic(), this.getData();
    },
    checkrouter: function() {
        try {
            var a = function() {
                for (var t = wx.getStorageSync("yz_basic_info"), a = t.popularize_page.mini.vue_route, e = 0; e < a.length; e++) if ("VideoReward" == a[e]) return wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: t.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
            }();
            if ("object" === t(a)) return a.v;
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    getStatistic: function() {
        var t = this, e = a.getNetAddresss("plugin.video-share.frontend.bonus.statistic");
        a._getNetWork({
            url: e,
            data: {},
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    rewards: e.data
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.video-share.frontend.bonus.getList");
        a._postNetWork({
            url: e,
            data: {
                page: 1
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.data.isLoadMore = !0, t.data.total_page = e.data.list.last_page, 
                t.data.total_page || (t.data.total_page = 0), t.setData({
                    recordsList: e.data.list.data
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getMoreData: function() {
        var t = this, e = a.getNetAddresss("plugin.video-share.frontend.bonus.getList");
        this.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        a._getNetWork({
            url: e,
            data: {
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    var o = e.data.list.data;
                    t.setData({
                        recordsList: t.data.recordsList.concat(o)
                    });
                } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
            },
            fail: function(t) {
                console.log(t);
            }
        }));
    }
});